<template>
	<view class="cu-card case">
		
		<view class="image">
			<image src="https://ossweb-img.qq.com/images/lol/web201310/skin/big10006.jpg"
			 mode="widthFix"></image>
		</view>
		<view class="cu-form-group">
			<view class="title">旧密码：</view>
			<input v-model="oldpassword" placeholder="输入旧密码" name="input"></input>
			<text class='cuIcon-safe text-blue'></text>
		</view>
		<view class="cu-form-group">
			<view class="title">新密码：</view>
			<input v-model="newpasswrod" placeholder="输入新密码" name="input"></input>
			<text class='cuIcon-safe text-red'></text>
		</view>
		<view class="padding flex flex-direction">
			<button class="cu-btn bg-red margin-tb-sm lg" @click="changedPassword">确认修改</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				oldpassword:"",
				newpasswrod:""
			}
		},
		methods: {
			async changedPassword() {
				console.log("dianji ta ")
				let username = JSON.parse(uni.getStorageSync("USERS_KEY")).username
			
				const res = await this.$myRequest({
					url: '/user/changePassword',
					data: {
						username: username,
						oldpassword: this.oldpassword,
						newpassword: this.newpasswrod
					},
			
			
				})
				if (res.data.indexOf("密码错误")==-1) {
					uni.showToast({
						title: "修改成功"
					})
				}else{
					uni.showToast({
						title: "请求失败"
					})
				}
			}
		}
	}
</script>

<style>

</style>
